﻿using System;
using UnityEngine;

// Token: 0x02000635 RID: 1589
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
	// Token: 0x170003EE RID: 1006
	// (get) Token: 0x06002542 RID: 9538 RVA: 0x00142850 File Offset: 0x00140A50
	public static T Instance
	{
		get
		{
			if (!global::Singleton<T>.instance)
			{
				global::Singleton<T>.instance = (T)((object)UnityEngine.Object.FindObjectOfType(typeof(T)));
				if (!global::Singleton<T>.instance)
				{
					global::Debug.LogError(typeof(T) + " is none.");
				}
			}
			return global::Singleton<T>.instance;
		}
	}

	// Token: 0x06002543 RID: 9539 RVA: 0x001428BC File Offset: 0x00140ABC
	public static bool IsInstance()
	{
		return null != global::Singleton<T>.instance;
	}

	// Token: 0x06002544 RID: 9540 RVA: 0x001428DC File Offset: 0x00140ADC
	protected virtual void Awake()
	{
		this.CheckInstance();
	}

	// Token: 0x06002545 RID: 9541 RVA: 0x001428E8 File Offset: 0x00140AE8
	public virtual bool CheckInstance()
	{
		if (this == global::Singleton<T>.Instance)
		{
			return true;
		}
		UnityEngine.Object.Destroy(this);
		return false;
	}

	// Token: 0x04002D3B RID: 11579
	protected static T instance;
}
